#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    vector<vector<int>> passengers(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        int len = (n - 1) - i;
        passengers[i].resize(len);
        for (int j = 0; j < len; ++j) {
            cin >> passengers[i][j];
        }
    }

    vector<vector<int>> sum(n + 1, vector<int>(n + 1, 0));
    for (int s = 1; s <= n - 1; ++s) {
        for (int e = s + 1; e <= n; ++e) {
            sum[s][e] = passengers[s - 1][e - s - 1];
        }
    }

    vector<int> c_values;
    for (int i = 1; i <= n - 1; ++i) {
        int total = 0;
        for (int s = 1; s <= i; ++s) {
            for (int e = i + 1; e <= n; ++e) {
                total += sum[s][e];
            }
        }
        c_values.push_back(total);
    }

    sort(c_values.rbegin(), c_values.rend());

    int res = 0;
    for (int i = 0; i < k; ++i) {
        res += c_values[i];
    }

    cout << res << endl;

    return 0;
}